package com.cd.service.user.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cd.bean.User;
import com.cd.dao.UserMapper;
import com.cd.service.user.UserService;

/**
 * 管理员（用户）接口
 *@Author zhk
 *@Date 2018-1-13
 **/
@Service("userService")
public class UserServiceImpl implements UserService{

	@Autowired
	UserMapper userMapper;
	
	@Override
	public void save(User user) throws Exception {
		userMapper.save(user);
	}

	@Override
	public void delete(Integer id) throws Exception {
		userMapper.delete(id);
	}

	@Override
	public void edit(User user) throws Exception {
		userMapper.update(user);
	}

	@Override
	public List<User> listAll() throws Exception {
		
		return userMapper.queryByList();
	}

	@Override
	public User findById(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return userMapper.query(id);
	}

	@Override
	public void deleteAll() throws Exception {
		
	}

	@Override
	public Integer size() throws Exception {
		// TODO Auto-generated method stub
		return userMapper.getCount();
	}

	@Override
	public User findByUsernameAndPwd(User user) throws Exception {
		return userMapper.queryByUsernameAndPwd(user);
	}
	/**
	 * 修改密码
	 */
	@Override
	public void updatePasswordById(User user) throws Exception {
		userMapper.updatePasswordById(user);
	}

	@Override
	public User findByUsername(String username) throws Exception {
		// TODO Auto-generated method stub
		return userMapper.findByUsername(username);
	}

	
	
	
	
}
